﻿Imports NHibernate
Imports NHibernate.Cfg
Imports SIAVU.Dominio

Public Class NHibernateHelper

    Private Shared _sessionFactory As ISessionFactory

    Private Shared ReadOnly Property SessionFactory() As ISessionFactory
        Get
            If _sessionFactory Is Nothing Then
                Dim configuration = New Configuration()
                configuration.Configure()
                configuration.AddAssembly(GetType(Usuario).Assembly)

                _sessionFactory = configuration.BuildSessionFactory()
            End If

            Return _sessionFactory
        End Get
    End Property



    Public Shared Function OpenSession() As ISession
        Return SessionFactory.OpenSession()
    End Function

    Public Shared Sub CloseSession()
        SessionFactory.Close()
    End Sub

End Class
